﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web;
using System.Web.Http;
using HCQ2_Common;
using HCQ2_Common.Attributes;
using HCQ2_Common.Encrypt;
using HCQ2_Common.Log;
using HCQ2_IBLL;
using HCQ2_Model;
using HCQ2_Model.Data;
using HCQ2_Model.Pay;
using HCQ2_Model.ViewModel;
using HCQ2_Model.ViewModel.WebAPI;
using HCQ2_Model.VR.Params;
using HCQ2_Model.WeiXinApiModel.Model;
using HCQ2WebAPI_Logic.BaseAPIController;
using HCQ2WebAPI_Logic.Filters;

namespace HCQ2WebAPI_Logic.DocumentController
{
    /// <summary>
    /// 购买相关接口
    /// </summary>
    [WeiXinApiAuthorizeFilter]
    public class PayController: BaseAPI
    {
        /// <summary>
        /// 购买相关
        /// </summary>
        public IT_VRShoppingCartBLL ShoppingCartBLL {
            get {
                return operateContext.bllSession.T_VRShoppingCart;
            }
        }
        /// <summary>
        /// 订单相关
        /// </summary>
        public IN_OrderBLL OrderBLL {
            get { return operateContext.bllSession.N_Order; }
        }
        /// <summary>
        /// 购物车相关
        /// </summary>
        public IN_ShoppingBLL ShoppingBLL {
            get { return operateContext.bllSession.N_Shopping; }
        }

        /// <summary>
        /// 获取订单列表
        /// </summary>
        /// <returns></returns>
        /// <remarks>
        /// 修改记录<br/>
        /// 2020-4-10：添加Search参数关键字，模糊匹配以下字段：订单号、商品名称、购买人<br/>
        /// 2021-8-2：添加请求参数，【VRType】依据禅道需求ID=146
        /// <br/>2021-9-15：添加需求《VLions需求规格_度度圈接口需求_订单及购物车-202100909.docx》的相关内容
        /// <br/>2021-9-16：禅道173号需求添加返回规格列表数据<br/>
        /// 2021-10-19：返回数据增加单价“UnitPrice”<br/>
        /// 2022-01-23：添加需求《度度圈需求规格-订单统计-20220120.docx》中内容，两个参数付款开始截止时间<br/>
        /// 2022-01-23：请求参数“SortType”添加类别： 2=按付款时间降序
        /// </remarks>
        [HttpPost]
        [ModelValid]
        public WebApiResultJsonModel<TableModel<List<OrderListModel>>> GetOrderList(GetOrderListParams listParams)
        {
            OperationResult<TableModel<List<OrderListModel>>> operationResult = OrderBLL.ListOrderList(listParams);

            return operationResult.ToWebApiResultJsonModelTData();            
        }
        /// <summary>
        /// 获取父订单展示列表
        /// </summary>
        /// <returns></returns>
        /// <remarks>
        /// 修改记录<br/>
        /// 2021-9-15：添加需求《VLions需求规格_度度圈接口需求_订单及购物车-202100909.docx》的相关内容<br/>
        /// 2021-9-16：禅道174号需求添加返回规格列表数据<br/>
        /// 2021-9-23：修改查询条件等相关内容，处理禅道174号需求。<br/>
        /// 2021-10-19：返回数据增加单价“UnitPrice”<br/>
        /// 2021-11-15：添加返回，订单和商铺的经纬度，距离，接单人姓名、接单人电话、接单人头像<br/>
        /// 2021-12-03：禅道需求239添加参数PackType<br/>
        /// </remarks>
        [HttpPost]
        [ModelValid]
        public WebApiResultJsonModel<GetParentOrderListTableModel> GetParentOrderList(GetParentOrderListParams listParams)
        {
            OperationResult<GetParentOrderListTableModel> operationResult = OrderBLL.ListParentOrderList(listParams);

            return operationResult.ToWebApiResultJsonModelTData();         
        }

        /// <summary>
        /// 获取订单详细
        /// </summary>
        /// <param name="detailedParams"></param>
        /// <returns></returns>
        /// <remarks>
        /// 修改记录<br/>
        /// 2020-09-18：取消“父单号”必填，添加“FileCode”和“OrderState”。参数验证修改，为空时FileCode和OrderState必填，不为空时忽略FileCode和OrderState。
        /// <br/>2021-9-16：禅道175号需求添加返回规格列表数据
        /// </remarks>
        [HttpPost]
        [ModelValid]
        public WebApiResultJsonModel<GetOrderDetailedModel> GetOrderDetailed(GetOrderDetailedParams detailedParams)
        {
            var data = OrderBLL.GetOrderDetailed(detailedParams);
            return data.ToWebApiResultJsonModelTData();
        }

        /// <summary>
        /// 获取订单支付金额
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        [ModelValid]
        public WebApiResultJsonModel<PaymentAmountModel> GetPaymentAmount(PaymentAmountParams paymentAmountParams)
        {
            OperationResult<PaymentAmountModel> operationResult = OrderBLL.GetPaymentAmount(paymentAmountParams);

            return operationResult.ToWebApiResultJsonModelTData();           
        }

        /// <summary>
        /// 提交订单;返回ParentOrderCode父单号
        /// </summary>
        /// <remarks>
        /// 创建订单的接口，创建成功后会返回“父单号”<br/>
        /// 以下情况无法提交订单：<br/>
        /// 1.提交订单中有商品已经存在“未付款订单”<br/>
        /// 2.提交订单中有商品已经购买<br/>
        /// 3.从购物车中提交订单，有商品在购物车不存在<br/>
        /// 4.获取不到商品的价格信息<br/>
        /// 注意：请求参数“SubmitType”设置正确，如果实际不是从购物车下单，设置为从购物车下单，这样是不行的。<br/>    
        /// 修改记录：<br/>
        /// 20210301：添加参数“FolderId”商铺ID<br/>
        /// 2022-04-08：添加参数，禅道需求286
        /// </remarks>
        [HttpPost]
        [ModelValid]
        public WebApiResultJsonModel<string> SubmitOrder(SubmitOrderParams submitOrderParams)
        {
            OperationResult<string> operationResult = OrderBLL.CreateOrder(submitOrderParams);
            return operationResult.ToWebApiResultJsonModelTData();
        }

        /// <summary>
        /// 获取微信openid
        /// </summary>
        /// <param name="code">微信用户登录凭证，使用 code 换取 openid 和 session_key 等信息</param>
        /// <param name="appId">小程序appId，如果不为空，那么去数据库中获取对应的密钥进行openId的获取，为空读取web.xml的appId和密钥进行openId获取</param>
        /// <returns></returns>
        /// <remarks>
        /// 修改记录：<br/>
        /// 2021-10-7：添加appId参数，根据传入appId从数据库中获取对应密钥进行openId生成，否则从web.xml中获取appId和密钥进行openId生成
        /// </remarks>
        [HttpGet]
        [SkipApi]
        public OperationResult<ChartUser> GetWebChartOpenId(string code, string appId = null)
        {
            var result = OrderBLL.GetWebChartOpenId(code, appId);

            return result;
        }

        /// <summary>
        /// 【VR设备购买时间使用】微信扫码支付，下单，返回微信预付单信息，通过预付单信息去打开支付
        /// </summary>
        /// <param name="createOrder">下单参数</param>
        /// <returns>返回微信预付单信息</returns>
        /// <remarks>
        /// 说明：接口内部会调用3个接口获取微信openid、创建系统内部订单生成单号、调用微信支付统一接口<br/> 
        /// 无法下单说明：<br/>
        /// 1.获取openid失败，无法下单。<br/>
        /// 2.创建系统内部订单失败无法下单，有如下三种情况。<br/>
        /// 2.1.如果设备已经支付购买有效期期内被再次扫码下单会提示：设备正在使用中，请等使用完毕再购买。<br/>
        /// 2.2.如果获取不到商品信息无法下单<br/>
        /// 2.3.如果获取不到价格信息无法下单<br/>
        /// 3.调用微信支付统一接口失败，无法下单<br/>       
        /// 
        /// 修改记录：<br/>
        /// 20201021：修改系统内下单验证，如果购买了并且未使用完时间，24小时内可以继续使用不用支付，返回结果：该设备已支付，欢迎体验
        /// 2021-10-7：添加参数"AppId"，当不为空去数据库配置表中找对应密钥进行对应小程序支付预负单信息获取，当为空采用web.xml中配置的小程序ID和密钥进行预付单信息获取。
        /// </remarks>
        [HttpPost]        
        [ModelValid]
        public WebApiResultJsonModel<WeChatUnifiedOrderModel> WebChartPreOrderPay(CreateOrder2Params createOrder)
        {
            var result = OrderBLL.WebChartPreOrderPay(createOrder);

            return result.ToWebApiResultJsonModelTData();
        }

        /// <summary>
        /// 【度度圈小程序使用】微信支付，下单，返回微信预付单信息，通过预付单信息去打开支付
        /// </summary>
        /// <param name="ddParams">下单参数</param>
        /// <returns>返回微信预付单信息</returns>
        /// <remarks>
        /// 说明：接口内部会调用3个接口获取微信openid、创建系统内部订单生成单号、调用微信支付统一接口<br/> 
        /// 无法下单说明：<br/>
        /// 1.获取openid失败，无法下单。<br/>
        ///
        /// 2.创建系统内部订单失败无法下单，有如下三种情况。<br/>        
        /// 2.1.提交订单中有商品已经存在“未付款订单”<br/>
        /// 2.2.提交订单中有商品已经购买<br/>
        /// 2.3.从购物车中提交订单，有商品在购物车不存在<br/>
        /// 2.4.获取不到商品的价格信息<br/>
        /// 
        /// 3.调用微信支付统一接口失败，无法下单<br/>       
        /// 
        /// 修改记录：
        /// 2021-09-14：添加需求《VLions需求规格_度度圈接口需求_订单及购物车-202100909.docx》的相关内容<br/>
        /// 2021-09-16：禅道170号需求添加规格列表参数<br/>
        /// 2021-10-07：添加参数"AppId"，当不为空去数据库配置表中找对应密钥进行对应小程序支付预负单信息获取，当为空采用web.xml中配置的小程序ID和密钥进行预付单信息获取。<br/>
        /// 2021-10-17：请求参数购买的商品信息中添加参数“Quantity”购买数量，计算金额时采用数量。<br/>
        /// 2021-10-27：返回参数中，添加一个“ParentOrderCode”本次系统内部的父单号。<br/>
        /// 2021-11-15：增加参数“GpsX”“GpsY”，“PackType”参数增加类别2外卖，禅道需求226号。<br/>
        /// 2021-11-17：增加折后金额计算，但是由于计算需要商铺ID所以只有当提交参数“FolderId”不为空才会计算<br/>
        /// </remarks>
        [HttpPost]        
        [ModelValid]
        public WebApiResultJsonModel<WeChatUnifiedOrderModel> WebChartPreOrderPayDD(WebChartPreOrderPayDDParams ddParams)
        {
            var result = OrderBLL.WebChartPreOrderPayDD(ddParams);

            return result.ToWebApiResultJsonModelTData();
        }

        /// <summary>
        /// 【度度圈网页使用】微信扫码支付，下单，返回微信二维码，用户微信扫码进行支付
        /// </summary>
        /// <param name="ddParams">下单参数</param>
        /// <returns>返回微信支付二维码，用微信扫码二维码进行支付</returns>
        /// <remarks>
        /// 说明：接口内部会调用2个接口：创建系统内部订单生成单号、调用微信支付统一接口得到微信二维码返回<br/> 
        /// 无法下单说明：<br/>
        /// 1.创建系统内部订单失败无法下单，有如下三种情况。<br/>        
        /// 1.1.提交订单中有商品已经存在“未付款订单”<br/>
        /// 1.2.提交订单中有商品已经购买<br/>
        /// 1.3.从购物车中提交订单，有商品在购物车不存在<br/>
        /// 1.4.获取不到商品的价格信息<br/>
        /// 
        /// 2.调用微信支付统一接口失败，无法下单<br/>       
        /// 
        /// 修改记录：<br/>
        /// 2022-06-06：修改返回结果，增加“父订单号”返回。<br/>
        /// </remarks>
        [HttpPost]        
        [ModelValid]
        public WebApiResultJsonModel<WebChartPreOrderPayDDQRCodeResultModel> WebChartPreOrderPayDDQRCode(WebChartPreOrderPayDDQRCodeParams ddParams)
        {
            var result = OrderBLL.WebChartPreOrderPayDDQRCode(ddParams);

            return result.ToWebApiResultJsonModelTData();
        }

        /// <summary>
        /// 未付款订单，生成微信扫码支付的二维码
        /// </summary>
        /// <param name="ddParams"></param>
        /// <returns></returns>
        /// <remarks>
        /// 说明：
        /// 如果订单不是“未付款”那么无法生成
        /// </remarks>
        [HttpPost]        
        [ModelValid]
        public WebApiResultJsonModel<WebChartPreOrderPayDDQRCodeResultModel> WebChartQRCodePayOrder(WebChartQRCodePayOrderParams ddParams)
        {
            var result = OrderBLL.WebChartQRCodePayOrder(ddParams);

            return result.ToWebApiResultJsonModelTData();
        }

        /// <summary>
        /// 订单支付(提交金币付款)
        /// </summary>
        /// <remarks>
        /// 此接口根据【提交订单】接口下单成功返回的“父单号”进行付款操作
        /// 以下情况无法进行支付：<br/>
        /// 1.未找到父单号<br/>
        /// 2.付款订单中有商品已经购买<br/>
        /// 3.无法获取到支付金额信息<br/>
        /// 4.用户金币赠币余额不足<br/>
        /// 5.通过父单号未找到订单信息<br/>
        /// 6.订单状态不是“未付款”<br/>
        /// 支付成功后会记录相关的扣减日志信息
        /// </remarks>
        [HttpPost]
        [ModelValid]
        public WebApiResultJsonModel<PayOrderModel> Payment(PaymentParams paymentParams)
        {
            OperationResult<PayOrderModel> operationResult = OrderBLL.PayOrder(paymentParams);

            return operationResult.ToWebApiResultJsonModelTData();          
        }

        /// <summary>
        /// 取消订单
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        [ModelValid]
        public WebApiResultJsonModel CancelOrder(OrderCancelParams cancelConfirmParams)
        {
            OperationResult operationResult = OrderBLL.CancelOrder(cancelConfirmParams);
            return operationResult.ToWebApiResultJsonModel();
        }

        /// <summary>
        /// 确认订单
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        [ModelValid]
        public WebApiResultJsonModel ConfirmOrder(OrderConfirmParams cancelConfirmParams)
        {
            OperationResult operationResult = OrderBLL.ConfirmOrder(cancelConfirmParams);
            return operationResult.ToWebApiResultJsonModel();
        }

        /// <summary>
        /// 支付密码验证;true正确/false错误
        /// </summary>
        /// <param name="payPwdCheckModel"></param>
        /// <remarks>
        /// 校验用户的支付密码是否正确
        /// </remarks>
        [HttpPost]
        [ModelValid]
        public WebApiResultJsonModel<bool> PayPwdCheck(PayPwdCheckModel payPwdCheckModel)
        {
            T_User user = operateContext.bllSession.T_User.FindSingle(w=>w.user_guid.Equals(payPwdCheckModel.userid));
            if (!string.IsNullOrEmpty(user.pay_pwd) && user.pay_pwd.Equals(EncryptHelper.Md5Encryption(payPwdCheckModel.PayPwd)))
            {
                return new WebApiResultJsonModel<bool>()
                {
                    errcode = HCQ2_Common.Constant.WebResultCode.Ok,
                    errmsg = "密码正确",
                    value = true
                };
            }
            return new WebApiResultJsonModel<bool>()
            {
                errcode = HCQ2_Common.Constant.WebResultCode.Exception,
                errmsg = "密码错误",
                value = false
            };
        }

        /// <summary>
        /// 获取订单数量
        /// </summary>
        /// <param name="getOrderTotalParams">订单状态;1(等待买家付款)、(2买家已付款)、4(交易成功)、5(交易关闭)、6(退款中)</param>
        /// <returns></returns>
        [HttpPost]
        [ModelValid]
        public WebApiResultJsonModel<Nullable<int>> GetOrderTotal(GetOrderTotalParams getOrderTotalParams)
        {
            int total = OrderBLL.GetOrderTotal(getOrderTotalParams);

            return new WebApiResultJsonModel<Nullable<int>>()
            {
                errcode = HCQ2_Common.Constant.WebResultCode.Ok,
                errmsg = "获取订单数量成功",
                value = total
            };
        }

        /// <summary>
        /// 添加商品进购物车
        /// </summary>
        /// <param name="shoppingAddParams">请求参数</param>
        /// <returns></returns>
        /// <remarks>
        /// 修改记录：<br/>
        /// 2021-9-14：添加需求《VLions需求规格_度度圈接口需求_订单及购物车-202100909.docx》的相关内容<br/>
        /// 2021-9-16：禅道170号需求添加规格列表参数<br/>
        /// 2021-10-3：老谭微信提出，实物商品可以重复添加，更新数量<br/>
        /// 2022-04-09：添加禅道需求284
        /// </remarks>
        [HttpPost]
        [ModelValid]
        public WebApiResultJsonModel ShoppingAdd(ShoppingAddParams shoppingAddParams)
        {
            var operationResult = ShoppingBLL.ShoppingAdd(shoppingAddParams);

            return operationResult.ToWebApiResultJsonModel();
        }

        /// <summary>
        /// 获取我的购物车列表
        /// </summary>
        /// <param name="shoppingListParams">请求参数</param>
        /// <returns></returns>
        /// <remarks>
        /// 2021-08-02:添加请求参数，【VRType】依据禅道需求ID=147<br/>
        /// 2021-09-16：禅道171号需求添加规格列表<br/>
        /// 2022-04-09：添加禅道需求283内容增加返回规格的价格，注意：如果加入购物车时传入的规格没有包含价格的那么价格可能为空，
        /// 比如：一个商品有：颜色和大小，两个规格，颜色没有价格，大小有价格区分，只传入了颜色没有传大小，那么规格价格就没有。<br/>
        /// </remarks>
        [HttpPost]
        [ModelValid]
        public WebApiResultJsonModel<TableModel<List<ShoppingList>>> GetShoppingList(ShoppingListParams shoppingListParams)
        {
            var operationResult = ShoppingBLL.ShoppingList(shoppingListParams);

            return operationResult.ToWebApiResultJsonModelTData();
        }

        /// <summary>
        /// 更新购物车列表
        /// </summary>
        /// <param name="shoppingUpdateParams"></param>
        /// <returns></returns>
        /// <remarks>
        /// 2022-04-09：禅道需求285，增加参数规格列表
        /// </remarks>
        [HttpPost]
        [ModelValid]
        public WebApiResultJsonModel UpdateShopping(ShoppingUpdateParams shoppingUpdateParams)
        {
            var operationResult = ShoppingBLL.UpdateShopping(shoppingUpdateParams);

            return operationResult.ToWebApiResultJsonModel();
        }

        /// <summary>
        /// 删除购物车中商品【new】
        /// </summary>
        /// <param name="param">购物车ID参数</param>
        /// <returns></returns>
        [HttpPost]
        [ModelValid]
        public WebApiResultJsonModel DeleteShopping(ShoppingDeleteParams param)
        {
            var operationResult = ShoppingBLL.DeleteShopping(param);

            return operationResult.ToWebApiResultJsonModel();
        }

        /// <summary>
        /// 确认发货
        /// </summary>
        /// <param name="param"></param>
        /// <returns></returns>
        [HttpPost]
        [ModelValid]
        public WebApiResultJsonModel ConfirmSendOutGoods(ConfirmSendOutGoodsParams param)
        {
            OperationResult operationResult = OrderBLL.ConfirmSendOutGoods(param);
            return operationResult.ToWebApiResultJsonModel();
        }

        /// <summary>
        /// 确认收货
        /// </summary>
        /// <param name="param"></param>
        /// <returns></returns>
        [HttpPost]
        [ModelValid]
        public WebApiResultJsonModel ConfirmReceivingGoods(ConfirmReceivingGoodsParams param)
        {
            OperationResult operationResult = OrderBLL.ConfirmReceivingGoods(param);
            return operationResult.ToWebApiResultJsonModel();
        }

        /// <summary>
        /// 获取我的订单统计
        /// </summary>
        /// <param name="param">请求参数</param>
        /// <returns></returns>
        /// <remarks>
        /// 修改记录：<br/>
        /// 2021-08-02:添加此接口，禅道需求ID=148<br/>
        /// 2021-10-20：老谭微信告知需要添加,禅道需求ID=196
        /// </remarks>
        [HttpPost]
        [ModelValid]
        public WebApiResultJsonModel<OrderStatisticsModel> OrderStatistics(OrderStatisticsParams param)
        {
            OperationResult<OrderStatisticsModel> operationResult = OrderBLL.OrderStatistics(param);
            return operationResult.ToWebApiResultJsonModelTData();
        }

        /// <summary>
        /// 更新订单备货状态
        /// </summary>
        /// <param name="param"></param>
        /// <returns></returns>
        /// <remarks>
        /// 2021-9-14：添加此接口，依据需求《VLions需求规格_度度圈接口需求_订单及购物车-202100909.docx》
        /// 2021-11-11：扩展接口StorageStatus参数最大到100，文档《UpdateStorageStatus接口取消状态限制.png》，后续状态是啥使用者自行定义。<br/>
        /// 2021-11-15：增加参数“ParentOrderCode”，取消参数“OrderCode”必填，但是“OrderCode”和“ParentOrderCode”不能同时为空，若都不为空，则优先 OrderCode，更新状态写日志记录        
        /// </remarks>
        [HttpPost]
        [ModelValid]
        public WebApiResultJsonModel UpdateStorageStatus(UpdateStorageStatusParams param) 
        {
            OperationResult operationResult = OrderBLL.UpdateStorageStatus(param);
            return operationResult.ToWebApiResultJsonModel();
        }

        /// <summary>
        /// 更新订单接单人信息
        /// </summary>
        /// <param name="param"></param>
        /// <returns></returns>
        /// <remarks>
        /// 修改记录：
        /// 2021-11-15：添加接口，禅道需求227<br/>
        /// </remarks>
        [HttpPost]
        [ModelValid]
        public WebApiResultJsonModel UpdateOrderReceivingUser(UpdateOrderReceivingUserParams param)
        {
            OperationResult operationResult = OrderBLL.UpdateOrderReceivingUser(param);
            return operationResult.ToWebApiResultJsonModel();
        }

        /// <summary>
        /// 按父订单号分组合计订单数量
        /// </summary>
        /// <param name="param"></param>
        /// <returns></returns>
        /// <remarks>
        /// 修改记录：
        /// 2021-11-15：添加接口，禅道需求229<br/>
        /// 2021-12-03：禅道需求238添加参数：FolderID、OrderState、PackType、SubmitType、VRType
        /// </remarks>
        [HttpPost]
        [ModelValid]
        public WebApiResultJsonModel GetParentGroupOrderTotal(GetParentGroupOrderTotalParams param) 
        {
            OperationResult operationResult = OrderBLL.GetParentGroupOrderTotal(param);
            return operationResult.ToWebApiResultJsonModel();
        }

        /// <summary>
        /// 获取店铺订单统计
        /// </summary>
        /// <param name="param"></param>
        /// <returns></returns>
        /// <remarks>
        /// 修改记录：<br/>
        /// 2022-01-23：需求《度度圈需求规格-订单统计-20220120.docx》添加
        /// </remarks>
        [HttpPost]
        [ModelValid]
        public WebApiResultJsonModel<GetStoreOrderStatModel> GetStoreOrderStat(GetStoreOrderStatParams param)
        {
            OperationResult<GetStoreOrderStatModel> result = OrderBLL.GetStoreOrderStat(param);

            return result.ToWebApiResultJsonModelTData();
        }

        /// <summary>
        /// 获取店铺商品销量统计
        /// </summary>
        /// <param name="param">请求参数</param>
        /// <returns></returns>
        /// <remarks>
        /// 修改记录：<br/>
        /// 2022-01-23：需求《度度圈需求规格-订单统计-20220120.docx》添加
        /// </remarks>
        [HttpPost]
        [ModelValid]
        public WebApiResultJsonModel<List<GetStoreGoodsStatModel>> GetStoreGoodsStat(GetStoreGoodsStatParams param)
        {
            OperationResult<List<GetStoreGoodsStatModel>> result = OrderBLL.GetStoreGoodsStat(param);

            return result.ToWebApiResultJsonModelTData();
        }

        /// <summary>
        /// 获取订单状态
        /// </summary>
        /// <param name="param">参数</param>
        /// <returns></returns>
        /// <remarks>
        /// value 订单状态：1(等待买家付款)、(2买家已付款)、4(交易成功)、5(交易关闭)、6(退款中) 、7(卖家已发货)
        /// </remarks>
        [HttpPost]
        [ModelValid]
        public WebApiResultJsonModel GetOrderState(GetOrderStateParams param)
        {
            var result = OrderBLL.GetOrderState(param);
            return result.ToWebApiResultJsonModel();
        }

        //[HttpGet]
        //public WebApiResultJsonModel Test(string userid) {

        //    //文件上传路径            
        //    string pathServer = "/uploadFile/DDQRCode/" + userid;
        //    string uploadPath = request.MapPath(request.ApplicationPath + pathServer);
        //    if (!System.IO.Directory.Exists(uploadPath))
        //        System.IO.Directory.CreateDirectory(uploadPath);

        //    string saveFilePath;
        //    string fileName = QRCodeHelper.CreateQRCode(uploadPath, "你好二维码", out saveFilePath);

        //    //二维码查看地址
        //    string qrcodeUrl = HttpContext.Current.Request.Url.AbsoluteUri.Substring(0, HttpContext.Current.Request.Url.AbsoluteUri.IndexOf("/api/")) + pathServer +"/"+ fileName;

        //    return new WebApiResultJsonModel(200,
        //}
    }
}
